import redis

class Database:
    def __init__(self, host='localhost', port=6379, db=0):
        self.r = redis.StrictRedis(host=host, port=port, db=db, decode_responses=True)

    def get_all_customers(self):
        return self.r.hgetall('tb_customer')

    def get_all_employees(self):
        return self.r.hgetall('tb_employee')

    def get_all_goods(self):
        return self.r.hgetall('tb_good')

    def get_all_pay_main(self):
        return self.r.hgetall('tb_pay_main')

    def get_all_pay_detail(self):
        return self.r.hgetall('tb_pay_detail')

    def add_customer(self, customer_id, customer_data):
        self.r.hset('tb_customer', customer_id, str(customer_data))

    def update_customer(self, customer_id, customer_data):
        self.r.hset('tb_customer', customer_id, str(customer_data))

    def delete_customer(self, customer_id):
        self.r.hdel('tb_customer', customer_id)

    def add_employee(self, employee_id, employee_data):
        self.r.hset('tb_employee', employee_id, str(employee_data))

    def update_employee(self, employee_id, employee_data):
        self.r.hset('tb_employee', employee_id, str(employee_data))

    def delete_employee(self, employee_id):
        self.r.hdel('tb_employee', employee_id)

    def add_good(self, good_id, good_data):
        self.r.hset('tb_good', good_id, str(good_data))

    def update_good(self, good_id, good_data):
        self.r.hset('tb_good', good_id, str(good_data))

    def delete_good(self, good_id):
        self.r.hdel('tb_good', good_id)

    def add_pay_main(self, pay_main_id, pay_main_data):
        self.r.hset('tb_pay_main', pay_main_id, str(pay_main_data))

    def update_pay_main(self, pay_main_id, pay_main_data):
        self.r.hset('tb_pay_main', pay_main_id, str(pay_main_data))

    def delete_pay_main(self, pay_main_id):
        self.r.hdel('tb_pay_main', pay_main_id)

    def add_pay_detail(self, pay_detail_id, pay_detail_data):
        self.r.hset('tb_pay_detail', pay_detail_id, str(pay_detail_data))

    def update_pay_detail(self, pay_detail_id, pay_detail_data):
        self.r.hset('tb_pay_detail', pay_detail_id, str(pay_detail_data))

    def delete_pay_detail(self, pay_detail_id):
        self.r.hdel('tb_pay_detail', pay_detail_id)

if __name__ == "__main__":
    db = Database()
    # Example usage
    print(db.get_all_customers())
    print(db.get_all_employees())
    print(db.get_all_goods())
    print(db.get_all_pay_main())
    print(db.get_all_pay_detail())
